package com.nari.ncps.screen.service.excelhandler.coal;

import cn.hutool.core.bean.BeanUtil;
import com.nari.ncps.screen.dto.excelimport.coal.CoalOpermonEquipFaultDto;
import com.nari.ncps.screen.service.coal.CoalOpermonEquipFaultService;
import com.nari.ncps.screen.service.excelhandler.ExcelDataHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CoalOpermonEquipFaultHandler implements ExcelDataHandler<CoalOpermonEquipFaultDto> {

    @Autowired
    private CoalOpermonEquipFaultService coalOpermonEquipFaultService;

    @Override
    public void handle(List<CoalOpermonEquipFaultDto> dataList) {
        try {
            // 保存煤炭产量数据
            List<com.nari.ncps.screen.entity.coal.CoalOpermonEquipFault> dbList =
                    BeanUtil.copyToList(dataList, com.nari.ncps.screen.entity.coal.CoalOpermonEquipFault.class);
            coalOpermonEquipFaultService.saveBatch(dbList);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
